package com.leo.customer.service.impl

import com.leo.customer.entity.dao.UserDao
import com.leo.customer.entity.pojo.User
import com.leo.customer.entity.pojo.UserVo
import com.leo.customer.manager.RedisManager
import com.leo.customer.service.UserService
import org.springframework.beans.BeanUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import javax.servlet.http.HttpServletRequest

@Service
class UserServiceImpl : UserService {

    @Autowired
    lateinit var userDao: UserDao

    @Autowired
    lateinit var redisManager: RedisManager

    override fun register(user: User): UserVo {
        val saveUser = userDao.save(user)
        val userVo = UserVo()
        BeanUtils.copyProperties(saveUser, userVo)
        userVo.token = saveUser.getToken()
        redisManager.setToken(userVo.token, userVo)
        return userVo
    }

    override fun generateToken() {

    }

    override fun login(user: User): UserVo {

        return UserVo()
    }

    override fun updateUser(user: User): User {
        return User()
    }
}
